<template>
  <div class="tabbar_content">
    <div class="tabbar_title">
      <span>公告列表</span>
      <el-button size="mini" class="reload_btn" @click="reload">刷新</el-button>
    </div>
    <div class="table_box">
      <el-table
        v-loading="loading"
        :data="tableData"
        border
        style="width: 50%"
      >
        <el-table-column
          fixed
          label="序号"
          type="index"
        />
        <el-table-column
          fixed
          prop="createTime"
          label="日期"
          width="180"
        />
        <el-table-column
          prop="name"
          label="公告"
          width="400"
        />
        <el-table-column
          fixed="right"
          label="操作"
          width="100"
        >
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="handleClick(scope.row)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="page_block">
      <el-pagination
        background
        layout="prev, pager, next"
        :page-size="pageSize"
        :total="total"
        @current-change="paginationChange"
      />
    </div>

  </div>
</template>
<script>
import cms from '@/api/cms'
export default {
  name: 'NoticeList',
  data() {
    return {
      name: 'NoticeList',
      formSearch: { createTime: [] },
      loading: true,
      tableData: [],
      pageSize: 20,
      pageIndex: 1,
      total: 0
    }
  },
  created() {
    this.init()// 页面自定义初始化
  },
  methods: {
    async init() {
      var that = this
      const params = {
        pageIndex: that.pageIndex,
        pageSize: that.pageSize,
        sortFields: 'id_a',
        queryList: []
      }
      const result = await cms.noticeList(params)
      if (result.code === 200) {
        that.loading = false
        that.tableData = result.data.records
        that.total = result.data.total
        console.log(that.total)
      }
    },
    reload() {
      this.loading = true
      this.init()
    },
    paginationChange(page) {
      this.pageIndex = page
      this.loading = true
      this.init()
    },
    handleClick(row) {
      console.log(row)
      this.$router.push('/noticeListEdit/edit/' + row.id)
    }
  }
}
</script>
<style lang="scss" scoped>
 .tabbar_content{
   width: 100%;
   height: 100%;
   background: white;
 }
 .table_box{
   border: 1px solid #ebebeb;
   border-radius: 3px;
   transition: .2s;
   padding: 20px;
 }
 .tabbar_title{
    border-bottom: solid 1px #dddee1;
    padding: 10px 10px;
    height: 50px;
    // line-height: 50px;
    line-height: 30px;
    font-size: 14px;
    color: #17233d;
    font-weight: 700;
    white-space: nowrap;
 }
 .tag_padding{
   margin-right:10px;
 }
 .page_block{
   padding: 15px 0;
   text-align: right;
 }
  .reload_btn{
   float:right;
 }
</style>
